#pragma once
#include <vector>

struct Detection {
  std::vector<float> box; // x0, y0, x1, y1
  float score;
  int class_id;
};

void process_boxes_with_nms(float *score[3], // [3][1*6*H*W]
                            float *box[3],   // [3][1*64*H*W]
                            const int h[3],  // [3]
                            const int w[3],  // [3]
                            float scale_x, float scale_y, float conf_thresh,
                            int reg_max,      // 一般16
                            float nms_thresh, // NMS IOU阈值
                            int max_det,      // 每类最大检测数
                            std::vector<Detection> &out_dets // 输出最终检测
);

float sigmoid(float x);
void softmax(const float *src, int len, float *dst);

float iou(const std::vector<float> &a, const std::vector<float> &b);
void nms_single_class(std::vector<Detection> &dets, float nms_thresh,
                      int max_det, std::vector<Detection> &result);